<?php
    include_once("../../service/articleService.php");
    include_once("../../service/userService.php");
    
    $pagegroup = $_GET["page"];
    $page = isset($_GET["p"])?$_GET["p"]:1;
    $record_per_page = 3;
    $start_record = ($page * $record_per_page) - ($record_per_page-1);
    $articles = getArticleOfPage($pagegroup,$start_record,$record_per_page);
 
    function truncate($text, $chars = 25) {
        $text = $text." ";
        $text = substr($text,0,$chars);
        $text = substr($text,0,strrpos($text,' '));
        $text = $text."...";
       return $text;
}
?>

<?php
    while($article = mysql_fetch_array($articles)){
?>
        <div class="wrapper-news">
        	<a href="./news-detail.php?a=<?php echo $article["ART_ID"]; ?>">
                <div class="wrapper-news-image">
                    <img src="<?php echo $article["ART_SMALLIMAGE"]; ?>"/>
                </div>
            </a>
        	<div class="wrapper-news-content">
            	<div class="news-title"><a href="./news-detail.php?a=<?php echo $article["ART_ID"]; ?>"><?php echo $article["ART_TITLE"]; ?></a></div>
            	    <?php echo truncate($article["ART_CONTENT"],200); ?>
                 <div class="view-detailed">
                 
                 <div style="float: right;">
                    <a style="color:red !important;" href="./news-detail.php?a=<?php echo $article["ART_ID"]; ?>">Xem thêm</a>
                 </div>
                 </div>
            </div>
            
        </div>       
<?php                                        
    }
?>
